import request from '@/utils/request'

const baseUrl = '/api/student'

/**
 * 学生字段
 */


//  学生课程分页
export function stuCoursePage(data: any) {
    return request({
        url: baseUrl + "/course/page",
        method: "post",
        data: data,
    });
}


//  学生课程查询
export function searchClasses(id: any, classes: any) {
    return request({
        url: baseUrl + "/course/search",
        method: "post",
        params: {
            id: id,
            classes: classes,
        }
    });
}

//  学生课程信息添加
export function joinClasses(id:any, number: any) {
    return request({
        url: baseUrl + "/course/join",
        method: "post",
        params:{
            id: id,
            number: number,
        }
    });
}

//  学生对应课程资源分页
export function resourceGet(data: any) {
    return request({
        url: "api/resource",
        method: "post",
        data: data,
    });
}

//  获取所有学生信息
export function studentGetAll(courseId: any,page: any,pageSize: any) {
    return request({
        url: baseUrl + "/course/all",
        method: "get",
        params:{
            courseId :courseId,
            page: page,
            pageSize: pageSize
        }
    });
}


//  获取学生作业信息
export function homeworkStuGetById(data: any) {
    return request({
        url: baseUrl + "/homework",
        method: "post",
        data:data,
    });
}


//  学生上传附件下载
export function homewordDownload(params: any) {
    return request({
        url: baseUrl + "/download",
        method: "get",
        params:{
            name: params,
        },
        headers:{
            contentType: 'multipart/form-data',
        }
    });
}



//  学生提交作业
export function homeworkStuSubmit(data: any) {
    return request({
        url: baseUrl + "/homework/submit",
        method: "post",
        data:data,
    });
}

//  获取学生作业信息
export function homeworkStuGet(data: any) {
    return request({
        url: baseUrl + "/homework/get",
        method: "post",
        data:data,
    });
}

//  学生作业下载
export function stuPreviewShow(annex: any) {
    return request({
        url: '/api/student/download',
        params: {
            name: annex,
        },
        method: "get",
        headers:{
            // application/msword 表示要处理为word格式
            // application/vnd.ms-excel 表示要处理为excel格式
            'Content-Type': 'application/json;charset=utf-8',
        },
        responseType:'blob' //在请求中加上这一行，特别重要
    });
}


//  学生撤销提交的作业
export function homeworkStuRevocation(data: any) {
    return request({
        url: baseUrl + "/homework/revocation",
        method: "post",
        data:data,
    });
}